package cn.iocoder.yudao.module.famous.doctor.dal.mysql.certificate;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.casehistory.CaseHistoryDO;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.certificate.FamCertificateDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.famous.doctor.controller.admin.certificate.vo.*;

import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

/**
 * 互联网备案 Mapper
 *
 * @author Test1
 */
@Mapper
public interface FamCertificateMapper extends BaseMapperX<FamCertificateDO> {

    default PageResult<FamCertificateDO> selectPage(FamCertificatePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FamCertificateDO>()
                .eqIfPresent(FamCertificateDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(FamCertificateDO::getCertificationGaintime, reqVO.getCertificationGaintime())
                .eqIfPresent(FamCertificateDO::getCertificationImageurl, reqVO.getCertificationImageurl())
                .eqIfPresent(FamCertificateDO::getCertificationNumber, reqVO.getCertificationNumber())
                .eqIfPresent(FamCertificateDO::getOccupationHospitalNumber, reqVO.getOccupationHospitalNumber())
                .betweenIfPresent(FamCertificateDO::getOccupationHospitalGaintime, reqVO.getOccupationHospitalGaintime())
                .eqIfPresent(FamCertificateDO::getCertificationTaxpayerNumber, reqVO.getCertificationTaxpayerNumber())
                .likeIfPresent(FamCertificateDO::getHospitalName, reqVO.getHospitalName())
                .eqIfPresent(FamCertificateDO::getOccupationHospitalImageurl, reqVO.getOccupationHospitalImageurl())
                .betweenIfPresent(FamCertificateDO::getCreateTime, reqVO.getCreateTime())
                .eq(FamCertificateDO::getCreator, getLoginUserId())
                .orderByDesc(FamCertificateDO::getId));
    }

    default List<FamCertificateDO> selectList(FamCertificateExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FamCertificateDO>()
                .eqIfPresent(FamCertificateDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(FamCertificateDO::getCertificationGaintime, reqVO.getCertificationGaintime())
                .eqIfPresent(FamCertificateDO::getCertificationImageurl, reqVO.getCertificationImageurl())
                .eqIfPresent(FamCertificateDO::getCertificationNumber, reqVO.getCertificationNumber())
                .eqIfPresent(FamCertificateDO::getOccupationHospitalNumber, reqVO.getOccupationHospitalNumber())
                .betweenIfPresent(FamCertificateDO::getOccupationHospitalGaintime, reqVO.getOccupationHospitalGaintime())
                .eqIfPresent(FamCertificateDO::getCertificationTaxpayerNumber, reqVO.getCertificationTaxpayerNumber())
                .likeIfPresent(FamCertificateDO::getHospitalName, reqVO.getHospitalName())
                .eqIfPresent(FamCertificateDO::getOccupationHospitalImageurl, reqVO.getOccupationHospitalImageurl())
                .betweenIfPresent(FamCertificateDO::getCreateTime, reqVO.getCreateTime())
                .eq(FamCertificateDO::getCreator, getLoginUserId())
                .orderByDesc(FamCertificateDO::getId));
    }

}
